﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using MyBlog.Model;

namespace MyBlog.Web
{
    /// <summary>
    /// 跟踪并记录日志
    /// </summary>
    public class TrackRequestAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                var log = new SysLogModel { OpDetail = filterContext.HttpContext.Request.Url.ToString(), OpIP = UserSession.GetClientIP(), OpName = "访问", OpTime = DateTime.Now };
                log.OpAccount = UserSession.LoginUserInfo == null ? "游客" : UserSession.AccountId;
                XiaoBoKe.SysLogService.Add(log);
            }
            catch { }
            base.OnActionExecuting(filterContext);
        }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);
        }

    }
}